package com.foo.ui_demo_widge;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.example.ui_demo_widget1.adapter.MyRecycleViewAdapter;

import java.util.ArrayList;
import java.util.List;

public class RecyclerViewActivity extends AppCompatActivity {
    private List<String> data;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);
        initdata();
        RecyclerView rvdemo = findViewById(R.id.rv_demo);
//        LinearLayoutManager layoutManager=new LinearLayoutManager(this);
//        layoutManager.setOrientation(RecyclerView.HORIZONTAL);
        GridLayoutManager layoutManager = new GridLayoutManager(this, 4);

        rvdemo.setLayoutManager(layoutManager);
        rvdemo.setAdapter(new MyRecycleViewAdapter(data,this));
    }

    private void initdata() {
        data=new ArrayList<String>();
        for(int i='a';i<'z';i++){
            data.add(" "+(char)i);

        }

    }
}